package com.zb.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.entity.ZjWithdrawVoucher;
import com.zb.mapper.ZjWithdrawVoucherMapper;
import com.zb.service.ZjWithdrawVoucherService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 提现凭证表 服务实现类
 * </p>
 *
 * @author WEN
 * @since 2024-06-15
 */
@Service
public class ZjWithdrawVoucherServiceImpl extends ServiceImpl<ZjWithdrawVoucherMapper, ZjWithdrawVoucher> implements ZjWithdrawVoucherService {

    // 根据提现单ID获取提现凭证
    @Override
    public List<String> getByWithdrawId(Long id) {
        QueryWrapper<ZjWithdrawVoucher> wrapper = new QueryWrapper<>();
        wrapper.select("path")
                .eq("withdraw_id", id);
        List<ZjWithdrawVoucher> voucherList = this.list(wrapper);
        if (CollectionUtil.isEmpty(voucherList)) {
            return new ArrayList<>();
        }
        return voucherList.stream().map(ZjWithdrawVoucher::getPath).toList();
    }
}
